<template>
  <div id="app">
    <Topbar :key="change"></Topbar>

    <!---->
    <Header></Header>
    <router-view />
    <Footer></Footer>
    <Login v-show="isShowLoginModal"></Login>
    <transition name="slide"> <Toast v-show="isShowToast"></Toast></transition>
  </div>
</template>
<script>
import Topbar from '@/components/Topbar.vue'
import Header from '@/components/Header.vue'
import Footer from '@/components/Footer.vue'
import axios from '@/request/request'
import Login from './components/Login.vue'
import { mapState } from 'vuex'
import Toast from '@/components/Toast.vue'
export default {
  components: {
    Topbar,
    Header,
    Footer,
    Login,
    Toast
  },
  created() {
    axios.get('/products').then((res) => {
      console.log(333)
      console.log(res)
      console.log(111)
      console.log('开发配置值为：', process.env.VUE_APP_STATE_URL1)
      console.log('生产配置值为：', process.env.VUE_APP_STATE_URL)
    })
  },
  mounted() {
    console.log(222)
  },
  computed: {
    ...mapState({
      isShowLoginModal: (state) => state.showModal.isShowLoginModal,
      isShowToast: (state) => state.showToast.isShowToast
    })
  },
  data() {
    return {
      change: 0
    }
  },
  watch: {
    '$route.path': {
      handler(newVal, old) {
        if (newVal != old) {
          this.change++
          // console.log(111)
        }
      }
    }
  }
}
</script>
<style lang="less">
.slide-enter,
.slide-leave-to {
  opacity: 0;
}

.slide-enter-active,
.slide-leave-active {
  transition: opacity 0.3s linear;
}

.slide-enter-to,
.slide-leave {
  opacity: 1;
}
</style>
